Stored Procedures [dbo].[BAEEventGetFunctionRegistrationCounts]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)
@eventCodevarchar(64)64
SQL Script
CREATE PROCEDURE [dbo].[BAEEventGetFunctionRegistrationCounts] @eventCode varchar(64)
AS
SELECT p.[PRODUCT_MINOR] AS 'FunctionCode', ISNULL(CONVERT(int, SUM(ol.[QUANTITY_ORDERED])), 0) AS 'NumberRegistered'
    FROM [dbo].[Product] p
    LEFT OUTER JOIN [dbo].[Order_Lines] AS ol ON p.[PRODUCT_CODE] = ol.[PRODUCT_CODE]
    WHERE p.[PRODUCT_MAJOR] = @eventCode
    GROUP BY p.[PRODUCT_MINOR]
    ORDER BY p.[PRODUCT_MINOR]

GO
Uses